//
//  TicketDetailCell.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/12/11.
//  Copyright © 2017年 AudioCtrip. All rights reserved.
//

#import "TicketDetailCell.h"

@implementation TicketDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.containerView.layer.cornerRadius = 10;
    self.containerView.clipsToBounds = YES;
    
}


- (void)configDataWith:(CompeleteTicketeModel *)model Pic:(NSString *)pic Title:(NSString *)title Date:(NSString *)date {
    
    self.numTipLabel.text = MYLocalizedString(@"TICKET_NUM_PSW", nil);
    [self.tickedtImageView setImageURL:[NSURL URLWithString:pic] placeholderImage:kPlaceholderSqu];
    
    self.nameLabel.text = title;
    
    if (date.length >0) {
        NSString * str2 = [NSString stringWithFormat:MYLocalizedString(@"TICKET_USE_DATE", nil),date];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str2];
        NSRange range = [str2 rangeOfString:date];
        
        attr.font = Font(12);
        attr.color = kSubitleColor;
        
        [attr addAttribute:NSForegroundColorAttributeName value:kThemeColor range:range];
        self.dateLabel.attributedText = attr;
    }
    
    
    if (model.type.integerValue == 1) {
        self.explainLabel.text = MYLocalizedString(@"TICKET_NUM_PSW", nil);
        self.numLabel.text = model.value;
        self.tipLabel.text = MYLocalizedString(@"TICKET_TYPE_PSW", nil);
        self.codeImageView.hidden = YES;
    }else {
        self.codeImageView.hidden = NO;
        [self.codeImageView setImageURL:[NSURL URLWithString:model.value] placeholderImage:kPlaceholderSqu];
        self.numLabel.text = @"";
        self.tipLabel.text = MYLocalizedString(@"TICKET_TYPE_QRCODE", nil);
    }
    
    self.explainLabel.text = [NSString stringWithFormat:@"%@%@",model.size,MYLocalizedString(@"TICKET_USE_PEOPLE_COUNT", nil)];
}
//-(void)setFrame:(CGRect)frame
//{
//    frame.origin.x = 9;//这里间距为10，可以根据自己的情况调整
//    frame.size.width -= 2 * frame.origin.x;
//    //frame.size.height -= frame.origin.x;
//    [super setFrame:frame];
//}

@end
